import http from '@/http/http'
import { AddArticleModel, ArticleListParam, ArticleParam } from './ArticleModel'

enum Api {
    getArticleList = '/api/v1/article/getList',
    addAndEditAndDel = '/api/v1/article/article',
    upload = '/api/v1/attach/upload'
}

// 获取文章列表
export const getArticleTableApi = async (param: ArticleListParam) => {
    return await http.get(Api.getArticleList, param)
}

// 获取单个文章
export const getArticleApi = async (param: ArticleParam) => {
    return await http.getRestApi(Api.addAndEditAndDel, param)
}

// 新增
export const addArticleApi = async (param: AddArticleModel) => {
    return await http.post(Api.addAndEditAndDel, param)
}
// 编辑
export const editArticleApi = async (param: AddArticleModel) => {
    return await http.put(Api.addAndEditAndDel, param)
}
// 删除
export const delArticleApi = async (param: ArticleParam) => {
    return await http.delete(Api.addAndEditAndDel, param)
}

export const getUploadUrlApi = () => {
    return http.baseUrl + Api.upload
}
